<?php
/*
 * Smarty plugin
 * -------------------------------------------------------------
 * File:     modifier.price_format.php
 * Type:     modifier
 * Name:     price_format
 * Purpose:  display formatted price
 * -------------------------------------------------------------
 */

function smarty_modifier_format_price($value, $currency=false) {
	global $env, $currencies;
	if (!$currency and isset($_SESSION['currency'])) $currency = $_SESSION['currency'];
	elseif (!$currency) $currency = $env['shop']['default_currency'];
	return sprintf($currencies[$currency]['format'], $value * $currencies[$currency]['exchange_rate']);
}

$smarty->register_modifier('format_price', 'smarty_modifier_format_price');
